#ifndef _FNT_SESSION_OPTIONS_H_
#define _FNT_SESSION_OPTIONS_H_

#include "options.page.h"
#include "xfunc.widget.h"

#include <QDoubleSpinBox>
#include <QGroupBox>
#include <QComboBox>
#include <array>
class SessionPriv;
// XXX get most hi-def cube from load.thread
class SessionLoadingOptions: public OptionsPage {
	SessionPriv* sp;

	bool disabled;

	double sightDef;
	double sightSet;

	QDoubleSpinBox* spin;

	static SessionLoadingOptions* _instance;

	SessionLoadingOptions();
	~SessionLoadingOptions();

	void getState(bool* a, bool* b, bool* c, bool* d) const override;
	void setStateImp(SessionState ts) override;
	void useDefaultImp() override;
	void saveDefaultImp() override;
	void applyChangesImp() override;
	void resetChangesImp() override;

	private Q_SLOTS:
		void sightChanged(double v);

	public:
	void config(SessionPriv* _vp, Options* options) const;
	void saveConfig(SessionPriv* _vp, Options* options) const;
	void attach(SessionPriv* _vp);

	static SessionLoadingOptions* instance() {
		if(!_instance)
			_instance=new SessionLoadingOptions{};
		return _instance;
	}
};

class SessionChannelOptions: public OptionsPage {
	SessionPriv* sp;
	bool disabled;
	bool disabled_xfunc_cube;
	SessionState sstate;

	std::array<QGroupBox*, 3> gboxes;
	std::array<int, 9> mapsSet;
	std::array<QComboBox*, 9> comboBoxes;
	std::array<XfuncWidget*, 9> xfuncWidgets;
	QVector<std::pair<double, double>> xfuncsSaved;

	SessionChannelOptions();
	~SessionChannelOptions();

	void getState(bool* a, bool* b, bool* c, bool* d) const override;
	void setStateImp(SessionState ts) override;
	void useDefaultImp() override;
	void saveDefaultImp() override;
	void applyChangesImp() override;
	void resetChangesImp() override;

	void setItems();
	void saveXfuncs(SessionPriv* sp);

	static SessionChannelOptions* _instance;

	private Q_SLOTS:
		void mapChanged(int i, int v);
		void xfuncChanged(int v);

	public:
	void config(SessionPriv* _vp, Options* options) const;
	void saveConfig(SessionPriv* _vp, Options* options) const;
	void attach(SessionPriv* _vp);

	static SessionChannelOptions* instance() {
		if(!_instance)
			_instance=new SessionChannelOptions{};
		return _instance;
	}
};

#endif
